﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ChatApp.Service.Business;
using ChatApp.Service.Model;

namespace ChatApp.Service
{
    public class ChatAppService : IChatAppService
    {
        #region User

        public UserBLL UserPro
        {
            get
            {
                return new UserBLL();
            }
        }

        public User LoginUser(string userName, string password)
        {
            return UserPro.LoginUser(userName, password);
        }

        public void CreateUser(User user)
        {
            UserPro.CreateUser(user);
        }

        public bool IsDuplicateUser(string userName)
        {
            return UserPro.IsDuplicateUser(userName);
        }

        public User RetrieveUserByUserName(string userName)
        {
            return UserPro.RetrieveUserByUserName(userName);
        }

        #endregion

        #region AddFriend

        public AddFriendBLL AddFriendPro
        {
            get
            {
                return new AddFriendBLL();
            }
        }

        public int CreateAddFriend(AddFriend addFriend)
        {
            return AddFriendPro.CreateAddFriend(addFriend);
        }

        public List<AddFriend> RetrieveAllAddFriend(string userName)
        {
            return AddFriendPro.RetrieveAllAddFriend(userName);
        }

        public bool IsDuplicateUserAdd(string userName, string userNameAdd)
        {
            return AddFriendPro.IsDuplicateUserAdd(userName, userNameAdd);
        }

        #endregion

        #region Message

        public MessageBLL MessagePro
        {
            get
            {
                return new MessageBLL();
            }
        }

        public int SendMessage(int idRoom, string tenRoom, bool laChatRoom, string userNameSend, string text, List<string> listUserNameReceive)
        {
            return MessagePro.SendMessage(idRoom, tenRoom, laChatRoom, userNameSend, text, listUserNameReceive);
        }

        #endregion

        public void RegisterClient(string userName)
        {
            ChatAppServiceGlobal.RegisterClient(userName);
        }
    }
}